package com.zis.system.web;

import com.zis.starter.core.ResponseEntity;
import com.zis.starter.core.SearchParams;
import com.zis.system.client.ResClient;
import com.zis.system.model.Res;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Create by wangshen 2018/3/28
 */
@RestController
@RequestMapping("/api/system/res")
public class ResController {

    @Autowired
    private ResClient resClient;

    /**
     * 分页查询
     * @param params
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public PageQuery<Res> findByPage(@RequestBody SearchParams params) throws Exception {
        return resClient.findByPage(params);
    }


    /**
     * 新增
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public ResponseEntity insert(@RequestBody Res model) throws Exception {
        return resClient.insert(model);
    }

    /**
     * 修改
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public ResponseEntity update(@RequestBody Res model) throws Exception {
        return resClient.update(model);
    }

    /**
     * 删除
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    public ResponseEntity delete(@PathVariable("id") String id) throws Exception {
        return resClient.delete(id);
    }

    /**
     * 查询tree
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/tree/json", method = RequestMethod.GET)
    public ResponseEntity findAllConvertTree() throws Exception {
        return resClient.findAllConvertTree();
    }
}
